package com.guoqiang.struct;

public class ForDemo02 {
    public static void main(String[] args) {
        // 计算0～100之间的奇数和偶数的和

        int oddSum = 0;
        int evenSum = 0;
        for (int i = 0; i <= 100; i++) {
            if (i % 2 == 0) {
                evenSum += i;
            } else
                oddSum += i;
        }
        System.out.println("1~100偶数的和为:" + evenSum);
        System.out.println("1~100奇数的和为:" + oddSum);
    }
}
